// import style from './style.module.less';
import './index.less'
import { useState, useEffect } from 'react'
const BaseContent = ({ request = () => { }, children, ...props }) => {

    const [allConlist, setallLlist] = useState([]);
    useEffect(() => {
        const req = request();
        if (req instanceof Promise) { //判断是否为promise 对象
            req.then((res) => {

                // console.log(res.data,'content');
                if (Array.isArray(res.data)) {
                    setallLlist(res.data); 
                } else {
                    throw new Error('BaseContent request 返回值不正确')
                }
            })
        } else {
            throw new Error('BaseContent request 返回值必须是promise对象')
        }
    }, [request])
    return (
        <div className={"basecenter"}>

            <div className="con">
                {
                    allConlist.length ? (
                        allConlist[0].map((item, index) => {
                            return children(item, index)
                        })

                    ) : (
                        <p>暂无数据</p>
                    )
                }
            </div>

        </div>
    )

}

export default BaseContent